<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">

<h:head></h:head>

<h:body>
	<div id="logoHomePage" align="left">
		<a href="../homepage.xhtml"><img src="../grafica/MeteoCal_Logo.gif" width="150" height="50"/></a>
	</div>
	
	<div id="logout" align="right">
   		<h:form>
			<h:commandButton action="#{logoutBean.logout}" value="Logout" />
		</h:form>
	</div>
	
	<p:panel>

		<div align="left"><h:link outcome="createevent" value="Create new event" /></div>
		<div align="left"><h:link outcome="notifications" value="View notifications" /></div>
		<br></br>
		<h:form>
		    <p:growl id="messages" showDetail="true" />
		 
		    <h:panelGrid columnClasses="value">
		        <h3 style="margin-top: 0">MeteoCal Schedule</h3>
		        <p:schedule id="schedule" value="#{scheduleView.eventModel}" widgetVar="myschedule" timeZone="GMT+2">
		 
		            <p:ajax event="dateSelect" listener="#{scheduleView.onDateSelect}" update="meteoDialog" oncomplete="PF('meteoDialog').show();" />
		            <p:ajax event="eventSelect" listener="#{scheduleView.onEventSelect}" update="eventDetails2,eventDetails" oncomplete="PF('eventDialog').show();" />
		            <p:ajax event="eventMove" listener="#{scheduleView.onEventMove}" update="messages" />
		            <p:ajax event="eventResize" listener="#{scheduleView.onEventResize}" update="messages" />
		 
		        </p:schedule>
		 
		    </h:panelGrid>
		 
		    <p:dialog widgetVar="eventDialog" header="Event Details" showEffect="clip" hideEffect="clip">
		        <h:panelGrid id="eventDetails" columns="2">
		        	<p>Weather: #{meteoBean.getWeather(scheduleView.magic,scheduleView.event.data.place)}<br></br>
	        		Max: #{meteoBean.getMaxTemp(scheduleView.magic,scheduleView.event.data.place)}F<br></br>
	        		Min: #{meteoBean.getMinTemp(scheduleView.magic,scheduleView.event.data.place)}F</p>
		        	<p:commandButton id="sModifyButton" value="Modify"  onclick="PF('eventDialog').hide();PF('modifyDialog').show();" />
		            <p:commandButton id="deleteButton" value="Delete" actionListener="#{scheduleView.deleteEvent(scheduleView.event.data)}" oncomplete="PF('myschedule').update();PF('eventDialog').hide();" />
		        </h:panelGrid>
		    </p:dialog>
		    
		    <p:dialog widgetVar="modifyDialog" header="Modify selected Event" showEffect="clip" hideEffect="clip">
		        <h:panelGrid id="eventDetails2" columns="2">
		    	
			    	<h:outputLabel for="name">Name:</h:outputLabel>
					<p:inputText id="name" value="#{scheduleView.event.data.name}" />
					<p:message for="name" />
					<br></br>
	
					<h:outputLabel for="description">Description:</h:outputLabel>
					<p:inputText id="description" value="#{scheduleView.event.data.description}" />
					<p:message for="description" />	
					<br></br>
				
					<h:outputLabel for="place">Place:</h:outputLabel>
					<p:inputText id="place" value="#{scheduleView.event.data.place}" />
					<p:message for="place" />
					<br></br>
	
					<h:outputLabel for="insideOutside">Inside or outside event?</h:outputLabel>
					<h:selectOneRadio id="insideOutside" value="#{scheduleView.event.data.insideOutside}">
					<f:selectItem itemLabel="Inside" itemValue="i" />
					<f:selectItem itemLabel="Outside" itemValue="o" />
					</h:selectOneRadio> 
					
					<h:outputLabel for="begin">Begin:</h:outputLabel>			
					<p:calendar id="begin" value="#{scheduleView.event.data.begin}" pattern="dd/MM/yyyy HH:mm:ss" />
					
					<h:outputLabel for="end">End:</h:outputLabel>				
					<p:calendar id="end" value="#{scheduleView.event.data.end}" pattern="dd/MM/yyyy HH:mm:ss" />
					<p></p>
					
					<p:commandButton id="modifyButton" value="Submit" actionListener="#{scheduleView.modifyEvent(scheduleView.event.data)}" oncomplete="PF('myschedule').update();PF('modifyDialog').hide();" />
					
		    	</h:panelGrid>
		    </p:dialog>
		    
		    <p:dialog widgetVar="meteoDialog" header="Meteo Info" showEffect="clip" hideEffect="clip">
	        <h:panelGrid id="meteoDialog" columns="2">
	        	Weather: #{meteoBean.getWeather(scheduleView.magic,"Milan")}<br></br>
	        	Max: #{meteoBean.getMaxTemp(scheduleView.magic,"Milan")}F<br></br>
	        	Min: #{meteoBean.getMinTemp(scheduleView.magic,"Milan")}F
	        </h:panelGrid>
	    	</p:dialog>
		       
		</h:form>
	 
		<script type="text/javascript">
		    PrimeFaces.locales['tr'] = {
		        closeText: 'kapat',
		        prevText: 'geri',
		        nextText: 'ileri',
		        currentText: 'bugün',
		        monthNames: ['Ocak','Şubat','Mart','Nisan','Mayıs','Haziran',
		            'Temmuz','Ağustos','Eylül','Ekim','Kasım','Aralık'],
		        monthNamesShort: ['Oca','Şub','Mar','Nis','May','Haz',
		            'Tem','Ağu','Eyl','Eki','Kas','Ara'],
		        dayNames: ['Pazar','Pazartesi','Salı','Çarşamba','Perşembe','Cuma','Cumartesi'],
		        dayNamesShort: ['Pz','Pt','Sa','Ça','Pe','Cu','Ct'],
		        dayNamesMin: ['Pz','Pt','Sa','Ça','Pe','Cu','Ct'],
		        weekHeader: 'Hf',
		        firstDay: 1,
		        isRTL: false,
		        showMonthAfterYear: false,
		        yearSuffix: '',
		        month: 'Ay',
		        week: 'Hafta',
		        day: 'Gün',
		        allDayText : 'Tüm Gün'
		    };
		</script>
		
		
		
		<style type="text/css">
		    .value {
		        width: 1000px;
		    }
		</style>
		
	</p:panel>    
	

	</h:body>
</html>
